const {claimsModel}=require('../models/claimsModels')
//销售员新增理赔订单
module.exports.pushClaims=async (proms)=>{
    const data=await claimsModel.create(proms);
    console.log(33,data);
    return data;
}
//销售员新增理赔订单
module.exports.getClaims=async ({pageSize, cueerntPage})=>{
     //总条数 数据
   const total=await claimsModel.countDocuments({delete:false});
   //总页数
   const pageCount=Math.ceil(total/pageSize);
    const data=await claimsModel.find({delete:false})
    .limit(pageSize - 0)
     .skip((cueerntPage - 1) * pageSize)
     .populate(
        {
          path:'belongToSales',
        }
      );
    ;
    return {total,pageCount,data};
}

//销售员修改理赔信息并提交
module.exports.modifyClaims=async (proms)=>{
    const data=await claimsModel.updateOne({_id:proms._id},proms);
    return data;
}
//管理员处理理赔信息
module.exports.applyClaims=async (proms)=>{
    const data=await claimsModel.updateOne({_id:proms._id},proms);
    return data;
}

//管理员删除理赔信息
module.exports.deleteClaims=async (proms)=>{
    console.log(33,proms);
    const data=await claimsModel.updateOne({_id:proms._id},proms);
    return data;
}